package com.ruoyi.system.service.impl;


import com.ruoyi.system.domain.EmpowermentTraining;
import com.ruoyi.system.mapper.EmpowermentTrainingMapper;
import com.ruoyi.system.service.IEmpowermentTrainingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * 赋能培训Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@Service
public class EmpowermentTrainingServiceImpl implements IEmpowermentTrainingService
{
    @Autowired
    private EmpowermentTrainingMapper empowermentTrainingMapper;

    /**
     * 查询赋能培训
     * 
     * @param trainingId 赋能培训主键
     * @return 赋能培训
     */
    @Override
    public EmpowermentTraining selectEmpowermentTrainingByTrainingId(String trainingId)
    {
        return empowermentTrainingMapper.selectEmpowermentTrainingByTrainingId(trainingId);
    }

    /**
     * 查询赋能培训列表
     * 
     * @param empowermentTraining 赋能培训
     * @return 赋能培训
     */
    @Override
    public List<EmpowermentTraining> selectEmpowermentTrainingList(EmpowermentTraining empowermentTraining)
    {
        return empowermentTrainingMapper.selectEmpowermentTrainingList(empowermentTraining);
    }

    /**
     * 新增赋能培训
     * 
     * @param empowermentTraining 赋能培训
     * @return 结果
     */
    @Override
    public int insertEmpowermentTraining(EmpowermentTraining empowermentTraining) {
        // 生成并设置格式化的 training_id
        empowermentTraining.setTrainingId("training-" + UUID.randomUUID().toString().replaceAll("[^0-9]", "").substring(0, 5));
        // 插入到数据库
        return empowermentTrainingMapper.insertEmpowermentTraining(empowermentTraining);
    }

    /**
     * 修改赋能培训
     * 
     * @param empowermentTraining 赋能培训
     * @return 结果
     */
    @Override
    public int updateEmpowermentTraining(EmpowermentTraining empowermentTraining)
    {
        return empowermentTrainingMapper.updateEmpowermentTraining(empowermentTraining);
    }

    /**
     * 批量删除赋能培训
     * 
     * @param trainingIds 需要删除的赋能培训主键
     * @return 结果
     */
    @Override
    public int deleteEmpowermentTrainingByTrainingIds(String[] trainingIds)
    {
        return empowermentTrainingMapper.deleteEmpowermentTrainingByTrainingIds(trainingIds);
    }

    /**
     * 删除赋能培训信息
     * 
     * @param trainingId 赋能培训主键
     * @return 结果
     */
    @Override
    public int deleteEmpowermentTrainingByTrainingId(String trainingId)
    {
        return empowermentTrainingMapper.deleteEmpowermentTrainingByTrainingId(trainingId);
    }
}
